package com.schoolCommunity.controller;


import com.schoolCommunity.entity.Information;
import com.schoolCommunity.entity.MailboxMember;
import com.schoolCommunity.service.MailboxMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author YTH
 * @since 2020-10-14
 */
@CrossOrigin
@RestController
public class MailboxMemberController {
    @Autowired
    private MailboxMemberService mailboxMemberService;

    //用户获取尚未阅读的邮件
    @GetMapping("/memberGetNoMail/{memberId}")
    public Information memberGetNoMail(@PathVariable("memberId") long memberId) {
        return mailboxMemberService.memberGetNoMail(memberId);
    }

    //用户获取所有邮件
    @GetMapping("/memberAllMail/{memberId}")
    public Information memberAllMail(@PathVariable("memberId") long memberId) {
        return mailboxMemberService.memberAllMail(memberId);
    }

    //管理员写邮件给用户
    @PostMapping("/mailboxMember")
    public Information adminSendToMember(@RequestBody MailboxMember mailboxMember) {
        System.out.println(mailboxMember);
        return mailboxMemberService.adminSendToMember(mailboxMember);
    }

    //管理员获取自己发送出去的邮箱
    @GetMapping("/GetSendFromAdmin/{adminId}")
    public Information GetSendFromAdmin(@PathVariable("adminId") long adminId) {
        return mailboxMemberService.GetSendFromAdmin(adminId);
    }

    //用户确认阅读了邮箱
    @GetMapping("/MemberQueRenMail/{MailId}")
    public Information MemberQueRenMail(@PathVariable("MailId") long MailId){
        return mailboxMemberService.MemberQueRenMail(MailId);
    }

}

